<?php
include("admin_check.php");
include_once("../function.php");
include_once("../class/bonus_class.php");
include_once("../class/ulevel_class.php");
include_once("../class/system_class.php");
session_start();
header("Content-Type: text/html;charset=utf-8");
checkqx(2,13);
$sys=new system_class();
$system=$sys->system_information(1);
$ulevel=new ulevel_class();

$sql="select sum(pv) as pv from member where 1=1";
$pv=getOne($sql);
if ($_POST['button2']){
        $sql="select * from member where ispay=1";
        $re=mysql_query($sql);
        $_bonus_cl=new bonus_class();
        while($rs=mysql_fetch_assoc($re)){
            $_iul=$ulevel->getulevelbyulevel($rs['ulevel']);
            $mepv=$rs['pv']*2;
            if($_iul['yl10']<$mepv){
                $cha=$_iul['yl10']-$rs['pv'];
                if($cha<$mepv){
                    $member_update['pv']=$rs['pv']+$cha;
                }
            }else{
                $member_update['pv']=$rs['pv']*2;
            }
            edit_update_cl("member",$member_update,$rs['id']);
        }
        edit_sql("update systemparameters set danjia=2 where id=1");
        echo "<script language=javascript>alert('积分拆分完成.');window.location.href='?'</script>";

}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>清空数据库</title>
    <link href="css/table.css" rel="stylesheet" type="text/css">
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <link href="../layui-master/dist/css/layui.css" rel="stylesheet" type="text/css">
    <script src="../layui-master/dist/layui.js"></script>
</head>

<body>
<table width="100%" cellpadding="3" cellspacing="1" border="0" align="center" class="layui-table" lay-skin="line">
    <tr>
        <td align="center" colspan="2"><strong><font color="#FF0000">注意：结算积分前请先做好数据备份</font></strong></td>
    </tr>
    <tr>
        <td align="right" width="50%" ><strong><font color="#FF0000">当前积分单价：</font></strong></td>
        <td align="left"><strong><font color="#FF0000"><?=$system['danjia']?></font></strong></td>
    </tr>
    <tr>
        <td align="right" width="50%" ><strong><font color="#FF0000">当前积分总量：</font></strong></td>
        <td align="left"><strong><font color="#FF0000"><?=$pv['pv']?></font></strong></td>
    </tr>
    <!--  <tr >-->
    <!--    <td align="center"><form id="form1" name="form1" method="post" action="">-->
    <!--    <input type="text" name="jq"/>-->
    <!--      <input name="button1" type="submit" class="layui-btn layui-btn-warm" id="button1" value="加权分红结算" onClick="{if(confirm('您确定要结算奖金吗?')){this.document.selform.submit();return true;}return false;}"/>-->
    <!--    </form></td>-->
    <!--  </tr>-->
    <tr >
        <td align="center" colspan="2"><form id="form1" name="form1" method="post" action="">
                <input name="button2" type="submit" class="layui-btn layui-btn-warm" id="button2" value="手动拆分" onClick="{if(confirm('您确定要拆分积分吗?')){this.document.selform.submit();return true;}return false;}"/>
            </form></td>
    </tr>
</table>
</body>
</html>